#include"commit.hpp"
#include"log.hpp"
using namespace std;


int main()
{
    //服务端创建管道
    Init init;//调构造
    Log log;
    //打开管道
    int fd=open(FIFO_FILE,O_RDONLY,MODE);
    if(fd==-1)
    {
        perror("open");
        exit(FIFO_OPEN_ERR);
    }
    log(Info,"open fifo success,fd:%d",fd);

    //开始通信 服务端进行读
    while(true)
    {
        char buf[1024]={0};
        int x=read(fd,buf,sizeof(buf));
        if(x>0)
        {
            cout<<"server say@"<<buf<<endl;
        }
        else if(x==0)
        {
            cout<<"client quit, me too"<<endl;
            break;
        }
        else break;
    }
    log(Info,"read fifo success");

    //关闭管道
    close(fd);

    //删除管道 调析构
    


    return 0;
}